package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.srwl.mytx.domain.User;

import java.util.Date;

public class CoinTransfer implements Parcelable {
    private String id;

    private String uId;

    private String tId;

    private Double amount;

    private Integer status;

    private Integer type;

    private Date created;

    private User targetUser;

    public CoinTransfer(String id, String uId, String tId, Double amount, Integer status, Integer type, Date created) {
        this.id = id;
        this.uId = uId;
        this.tId = tId;
        this.amount = amount;
        this.status = status;
        this.type = type;
        this.created = created;
    }

    public CoinTransfer() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId == null ? null : uId.trim();
    }

    public String gettId() {
        return tId;
    }

    public void settId(String tId) {
        this.tId = tId == null ? null : tId.trim();
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public User getTargetUser() {
        return targetUser;
    }

    public void setTargetUser(User targetUser) {
        this.targetUser = targetUser;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.uId);
        dest.writeString(this.tId);
        dest.writeValue(this.amount);
        dest.writeValue(this.status);
        dest.writeValue(this.type);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
    }

    protected CoinTransfer(Parcel in) {
        this.id = in.readString();
        this.uId = in.readString();
        this.tId = in.readString();
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
    }

    public static final Creator<CoinTransfer> CREATOR = new Creator<CoinTransfer>() {
        @Override
        public CoinTransfer createFromParcel(Parcel source) {
            return new CoinTransfer(source);
        }

        @Override
        public CoinTransfer[] newArray(int size) {
            return new CoinTransfer[size];
        }
    };
}